using UnityEngine;

public static class Vector3Ex
{
	public static Vector3 Abs(Vector3 vec)
	{
		return new Vector3(Mathf.Abs(vec.x), Mathf.Abs(vec.y), Mathf.Abs(vec.z));
	}

	public static Vector3 Sign(Vector3 vec)
	{
		return new Vector3(Mathf.Sign(vec.x), Mathf.Sign(vec.y), Mathf.Sign(vec.z));
	}

	public static Vector3 Min(Vector3 a, Vector3 b)
	{
		return new Vector3(MathEx.Min(a.x, b.x), MathEx.Min(a.y, b.y), MathEx.Min(a.z, b.z));
	}

	public static Vector3 AbsMin(Vector3 a, Vector3 b)
	{
		return new Vector3(MathEx.AbsMin(a.x, b.x), MathEx.AbsMin(a.y, b.y), MathEx.AbsMin(a.z, b.z));
	}

	public static Vector3 CatmullRomLerp(Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4, float t)
	{
		t = Mathf.Clamp01(t);
		float num = t * t;
		float num2 = t * t * t;
		float num3 = -1f * num2 + 2f * num - t;
		float num4 = 3f * num2 - 5f * num + 2f;
		float num5 = -3f * num2 + 4f * num + t;
		float num6 = num2 - num;
		float num7 = 0.5f;
		return num7 * (num3 * p1 + num4 * p2 + num5 * p3 + num6 * p4);
	}

	public static Vector3 MainCameraWorldToUICameraWorld(Vector3 mainCameraPosition, Vector3 uiTransformPos)
	{
		Vector3 position = Camera.main.WorldToScreenPoint(mainCameraPosition);
		Vector3 result = UICamera.mainCamera.ScreenToWorldPoint(position);
		result.z = uiTransformPos.z;
		return result;
	}

	public static Vector3 Mirror(this Vector3 vector)
	{
		return new Vector3(0f - vector.x, vector.y, 0f - vector.z);
	}

	public static Vector3 OnGround(this Vector3 vector, float y = 0f)
	{
		Vector3 result = vector;
		result.y = y;
		return result;
	}

	public static float HorizontalDistance(Vector3 a, Vector3 b)
	{
		float num = b.x - a.x;
		float num2 = b.z - a.z;
		return Mathf.Sqrt(num * num + num2 * num2);
	}

	public static Vector3 LerpNotClamped(Vector3 from, Vector3 to, float tNotClamped)
	{
		return from + (to - from) * tNotClamped;
	}

	public static Vector3 LeftHandCross(Vector3 a, Vector3 b)
	{
		Vector3 result = Vector3.Cross(a, b);
		result.z *= -1f;
		return result;
	}

	public static Vector3 GetReverseHandedVector(this Vector3 vector)
	{
		Vector3 result = vector;
		result.z *= -1f;
		return result;
	}
}
